package com.example.hotbar;

import android.os.Bundle;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

public class SearchCityActivity extends Activity implements OnClickListener{

	EditText searchCityEditText;
	//, sqlName, sqlLocation;
	Button sqlSearch;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_search_city);
		sqlSearch = (Button) findViewById(R.id.searchcity);
		searchCityEditText = (EditText) findViewById(R.id.searchCityEditText);
		
		sqlSearch.setOnClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.search_city, menu);
		return true;
	}
	
	
	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		switch (arg0.getId()){
		
		case R.id.searchcity:
			try{
				String etBarLocationSearch = searchCityEditText.getText().toString();
				Bundle dataStream = new Bundle();
				//HotBarDB data = new HotBarDB(SearchCityActivity.this);
				//String newData  = data.getAllBarsInCity(etBarLocationSearch);
				dataStream.putString("key", etBarLocationSearch);
				
				Intent i = new Intent(SearchCityActivity.this, SearchByCityView.class);
				 i.putExtras(dataStream);
				startActivity(i);
				
				
				//sqlName.setText(returnedBar);
				//sqlLocation.setText(returnedLocation);
				 
			
				
			}catch (Exception e){
				//didItWork = false;
				String error = e.toString();
				Dialog d = new Dialog(this);
				d.setTitle("Dang IT!");
				TextView tv = new TextView(this);
				tv.setText(error);
				d.setContentView(tv);
				d.show();
		}
			break;
			
	}

}
}
